package com.wwz.controller;


import cn.hutool.core.util.StrUtil;
import com.wwz.feign.ChargeClients;
import com.wwz.feign.PersonnelClients;
import com.wwz.pojo.Charge;
import com.wwz.pojo.Personnel;
import com.wwz.pojo.query.ChargeQuery;
import com.wwz.pojo.query.PersonnelQuery;
import com.wwz.util.EcoBootException;
import com.wwz.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * admin管理
 * @date 2022/02/18 27:11:38
 */
@RestController
@RequestMapping("/centre/adminManage")
@Api(tags = "admin管理")
public class AdminManageController {

    @Resource
    private PersonnelClients personnelClients;

    @ApiOperation("获取人事列表")
    @GetMapping("/personnelList")
    public Result getPersonnelList(PersonnelQuery query){
        return personnelClients.toPage(query);
    }

    @ApiOperation("添加或修改人事信息")
    @PostMapping("/personnel/addOrUpdate")
    public Result addOrUpdate(@RequestBody Personnel personnel){
        if (personnel == null ){
            throw new EcoBootException("信息不能为空");
        }
        return personnelClients.addOrUpdate(personnel);
    }

    @ApiOperation("删除人事信息")
    @DeleteMapping("/personnel/delete/{id}")
    public Result deletePersonnel(@PathVariable String id){
        return personnelClients.delete(id);
    }

}
